<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        $this->_helper->layout->setLayout('main');
    }

    public function indexAction()
    {
        $this->_helper->layout->setLayout('main');
        //выводим две последнии новости
        $obj = new Application_Model_News();
        $news = $obj->getTwoLastNews();
        
        $this->view->news = $news;
    }

    public function contactsAction()
    {
        // action body
    }

    public function aboutAction()
    {
        // action body
    }

    public function ourworkAction()
    {
        $this->_helper->redirector('ourworkgrid', 'index');
    }

    public function ourworkgridAction()
    {
        $obj = new Application_Model_Projects();
        $id = $this->_getParam('cat');
        if ($id === 'all') {
            $projects = $obj->getAllProjects();
        } else {
            $projects = $obj->getAllCatProjects($id);
        }
        $page = $this->_getParam('page', 1);
        $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($projects));
        $paginator->setItemCountPerPage(2);
        $paginator->setCurrentPageNumber($page);
        $this->view->projects = $paginator;
        
        $cat = new Application_Model_Category();
        $category = $cat->getAllCategories();
        $this->view->cat = $category;
    }

    public function ourworksingleAction()
    {
        $id = $this->_getParam('id');
        $obj = new Application_Model_Projects();
        $projects = $obj->getSelectProject($id);
        $slider = $obj->getSliderImages($id);
        $this->view->slider = $slider;
        $this->view->projects = $projects;
    }

    public function blogAction()
    {
        // action body
    }

    public function blogsingleAction()
    {
        // action body
    }

    public function ourworklistAction()
    {
        $obj = new Application_Model_Projects();
        $id = $this->_getParam('cat');
        if ($id === 'all') {
            $projects = $obj->getAllProjects();
        } else {
            $projects = $obj->getAllCatProjects($id);
        }
        $page = $this->_getParam('page', 1);
        $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($projects));
        $paginator->setItemCountPerPage(2);
        $paginator->setCurrentPageNumber($page);
        $this->view->projects = $paginator;
        
        $cat = new Application_Model_Category();
        $category = $cat->getAllCategories();
        $this->view->cat = $category;
    }

    public function vacancyAction()
    {
        $obj = new Application_Model_Vacancy();
        $all = $obj->getAllVacancy();
        $this->view->all = $all;        
    }

    public function mediaAction()
    {
        $obj = new Application_Model_Media();
        $all = $obj->getAllMedia();
        $this->view->all = $all;
    }

    public function mediasingleAction()
    {
        $id = $this->_getParam('id', 0);
        $obj = new Application_Model_Media();
        $single = $obj->getSelectMedia($id);
        $this->view->single = $single;
    }


}













